package com.lxh.weekendmvc.web.controller;


import com.lxh.weekendmvc.common.Const;
import com.lxh.weekendmvc.entity.Emp;
import com.lxh.weekendmvc.services.EmpServices;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

@Controller
public class SystemController {
    @Autowired
    private EmpServices empServices;

    @RequestMapping("/login")
    public String login(String ename, String pwd, HttpSession session){
        Emp emp = empServices.doLogin(ename,pwd);
        if(emp!=null){
            session.setAttribute(Const.IS_LOGIN, emp);
            return "redirect:/emp/getEmpByPage";
        }
        return "redirect:/login.jsp";
    }



}
